Ternary Operation
   HOME

TheInfoList



OR:

In
mathematics Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
, a ternary operation is an ''n''- ary
operation Operation or Operations may refer to: Arts, entertainment and media * ''Operation'' (game), a battery-operated board game that challenges dexterity * Operation (music), a term used in musical set theory * ''Operations'' (magazine), Multi-Ma ...
with ''n'' = 3. A ternary operation on a
set Set, The Set, SET or SETS may refer to: Science, technology, and mathematics Mathematics *Set (mathematics), a collection of elements *Category of sets, the category whose objects and morphisms are sets and total functions, respectively Electro ...
''A'' takes any given three elements of ''A'' and combines them to form a single element of ''A''. In
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
, a ternary operator is an operator that takes three
arguments An argument is a statement or group of statements called premises intended to determine the degree of truth or acceptability of another statement called conclusion. Arguments can be studied from three main perspectives: the logical, the dialectic ...
as input and returns one output.


Examples

The
function Function or functionality may refer to: Computing * Function key, a type of key on computer keyboards * Function model, a structured representation of processes in a system * Function object or functor or functionoid, a concept of object-oriente ...
T(a, b, c) = ab + c is an example of a ternary operation on the
integer An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign (−1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
s (or on any structure where + and \times are both defined). Properties of this ternary operation have been used to define
planar ternary ring In mathematics, an algebraic structure (R,T) consisting of a non-empty set R and a ternary mapping T \colon R^3 \to R \, may be called a ternary system. A planar ternary ring (PTR) or ternary field is special type of ternary system used by Marsh ...
s in the foundations of
projective geometry In mathematics, projective geometry is the study of geometric properties that are invariant with respect to projective transformations. This means that, compared to elementary Euclidean geometry, projective geometry has a different setting, pro ...
. In the
Euclidean plane In mathematics, the Euclidean plane is a Euclidean space of dimension two. That is, a geometric setting in which two real quantities are required to determine the position of each point ( element of the plane), which includes affine notions of ...
with points ''a'', ''b'', ''c'' referred to an origin, the ternary operation
, b, c The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline (t ...
= a - b + c has been used to define
free vector In mathematics, physics, and engineering, a Euclidean vector or simply a vector (sometimes called a geometric vector or spatial vector) is a geometric object that has magnitude (or length) and direction. Vectors can be added to other vectors ac ...
s. Since (''abc'') = ''d'' implies ''a'' – ''b'' = ''c'' – ''d'', these directed segments are equipollent and are associated with the same free vector. Any three points in the plane ''a, b, c'' thus determine a
parallelogram In Euclidean geometry, a parallelogram is a simple (non- self-intersecting) quadrilateral with two pairs of parallel sides. The opposite or facing sides of a parallelogram are of equal length and the opposite angles of a parallelogram are of equa ...
with ''d'' at the fourth vertex. In
projective geometry In mathematics, projective geometry is the study of geometric properties that are invariant with respect to projective transformations. This means that, compared to elementary Euclidean geometry, projective geometry has a different setting, pro ...
, the process of finding a
projective harmonic conjugate In projective geometry, the harmonic conjugate point of an ordered triple of points on the real projective line is defined by the following construction: :Given three collinear points , let be a point not lying on their join and let any line t ...
is a ternary operation on three points. In the diagram, points ''A'', ''B'' and ''P'' determine point ''V'', the harmonic conjugate of ''P'' with respect to ''A'' and ''B''. Point ''R'' and the line through ''P'' can be selected arbitrarily, determining ''C'' and ''D''. Drawing ''AC'' and ''BD'' produces the intersection ''Q'', and ''RQ'' then yields ''V''. Suppose ''A'' and ''B'' are given sets and \mathcal(A, B) is the collection of
binary relation In mathematics, a binary relation associates elements of one set, called the ''domain'', with elements of another set, called the ''codomain''. A binary relation over Set (mathematics), sets and is a new set of ordered pairs consisting of ele ...
s between ''A'' and ''B''.
Composition of relations In the mathematics of binary relations, the composition of relations is the forming of a new binary relation from two given binary relations ''R'' and ''S''. In the calculus of relations, the composition of relations is called relative multiplica ...
is always defined when ''A'' = ''B'', but otherwise a ternary composition can be defined by
, q, r The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline o ...
= p q^T r where q^T is the
converse relation In mathematics, the converse relation, or transpose, of a binary relation is the relation that occurs when the order of the elements is switched in the relation. For example, the converse of the relation 'child of' is the relation 'parent& ...
of ''q''. Properties of this ternary relation have been used to set the axioms for a
heap Heap or HEAP may refer to: Computing and mathematics * Heap (data structure), a data structure commonly used to implement a priority queue * Heap (mathematics), a generalization of a group * Heap (programming) (or free store), an area of memory f ...
. In
Boolean algebra In mathematics and mathematical logic, Boolean algebra is a branch of algebra. It differs from elementary algebra in two ways. First, the values of the variables are the truth values ''true'' and ''false'', usually denoted 1 and 0, whereas in e ...
, T(A,B,C) = AC+(1-A)B defines the formula (A \lor B) \land (\lnot A \lor C).


Computer science

In computer science, a ternary operator is an operator that takes three arguments (or operands). The arguments and result can be of different types. Many
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
s that use C-like syntax feature a ternary operator, ?:, which defines a
conditional expression Conditional (if then) may refer to: *Causal conditional, if X then Y, where X is a cause of Y *Conditional probability, the probability of an event A given that another event B has occurred *Conditional proof, in logic: a proof that asserts a co ...
. In some languages, this operator is referred to as the ''conditional operator''. In
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
, the ternary conditional operator reads x if C else y. Python also supports ternary operations called array slicing, e.g. a :c/code> return an array where the first element is a /code> and last element is a -1/code>.
OCaml OCaml ( , formerly Objective Caml) is a general-purpose programming language, general-purpose, multi-paradigm programming language which extends the Caml dialect of ML (programming language), ML with object-oriented programming, object-oriented ...
expressions provide ternary operations against records, arrays, and strings: a. -c would mean the string a where index b has value c. The
multiply–accumulate operation In computing, especially digital signal processing, the multiply–accumulate (MAC) or multiply-add (MAD) operation is a common step that computes the product of two numbers and adds that product to an accumulator. The hardware unit that performs ...
is another ternary operator. Another example of a ternary operator is ''between'', as used in SQL. The
Icon programming language : Icon is a very high-level programming language based on the concept of "goal-directed execution" in which code returns a "success" along with valid values, or a "failure", indicating that there is no valid data to return. The success and failure ...
has a "to-by" ternary operator: the expression 1 to 10 by 2 generates the
odd Odd means unpaired, occasional, strange or unusual, or a person who is viewed as eccentric. Odd may also refer to: Acronym * ODD (Text Encoding Initiative) ("One Document Does it all"), an abstracted literate-programming format for describing X ...
integers from 1 through 9. In Excel formulae, the form is =if(C, x, y).


See also

*
Median algebra In mathematics, a median algebra is a set with a ternary operation \langle x,y,z \rangle satisfying a set of axioms which generalise the notions of medians of triples of real numbers and of the Boolean majority function. The axioms are # \langl ...
* ?: for a list of ternary operators in computer programming languages


References


External links

*{{Commons category-inline, Ternary operations